use std::{mem::size_of, os::raw::c_void};

use ash::vk::{self, DescriptorSet};
use cgmath::Zero;

use crate::{system::{render::{RenderSystem, render_scene::PerMeshUniformData}, scene::SceneSystem}, vulkan::{vk_context, vk_struct::{VkBuffer, VkDescriptorSet, VkMappedBuffer, VkWriteDescriptorSetGenerator}, vk_utils::utils_info, VkContext}, VK_CHECK_UNSAFE, VK_LOGD, VK_LOGP};

use super::{ObjectBase, ObjectTrait};

pub struct StaticMeshObject {
    pub object_base             : ObjectBase,

    time_step                   : f32
}

impl StaticMeshObject {
    pub fn new(id: usize, render_system: &mut RenderSystem) -> Self {
        Self {
            object_base             : ObjectBase::new(id, render_system),
            time_step               : 0.0
        }
    }
}

impl ObjectTrait for StaticMeshObject {
    fn get_model_mat(&self) -> cgmath::Matrix4<f32> {
        self.object_base.get_model_mat()
    }

    fn get_id(&self) -> usize {
        self.object_base.id
    }

    fn tick(&mut self, delta_time: f32) {
        self.time_step = self.time_step + delta_time;

        // self.object_base.location   = cgmath::Vector3::new(self.object_base.id as f32 * 2.0 + f32::sin(self.time_step), f32::cos(self.time_step), self.object_base.id as f32 * 2.0 + f32::sin(self.time_step));
        self.object_base.rotation   = cgmath::Vector3::new(self.time_step * 8.0, self.time_step * 4.0, self.time_step * 2.0);
        self.object_base.scale      = cgmath::Vector3::new(f32::sin(self.time_step) / 4.0 + 0.75, f32::sin(self.time_step) / 4.0 + 0.75, f32::sin(self.time_step) / 4.0 + 0.75);
    }
}